'''
Created on Apr 2, 2012

@author: mariano
'''

class ScoreSpriteUtility(object):
    '''
    Function to generate every Score position
    '''


    def __init__(self):
        '''
        Builds the utility
        '''
        self.offset = 0
        self.max_column = 2
        self.current_column = 0
        self.current_row = 0

    def _calc_position(self):
        initial_position = (66, 660)
        column = initial_position[0] + 27 * self.current_column + self.offset
        row = initial_position[1] - 26 * self.current_row
        return  column, row

    def generate_initial_positions(self):
        """ Creates every posible position for the score. """
        initial_positions = []
        for _ in range(50):
            initial_positions.append(self._generate_next_position())
        return initial_positions



    def _update_next_position(self):
        self.current_column += 1
        if self.current_column > self.max_column:
            self.current_column = 0
            self.current_row += 1
            if self.max_column == 2:
                self.max_column = 1
                self.offset = 13
            else:
                self.max_column = 2
                self.offset = 0

    def _generate_next_position(self):
        result = self._calc_position()
        self._update_next_position()
        return result
